from die import Die
import pygal
die = Die()
# 掷几次骰子，并将结果存储在一个列表中
results = []
for roll_num in range(100):
    result = die.roll()
    results.append(result)

    # 分析结果
    frequencies = []
    for value in range(1, die.num_sides+1):
        frequency = results.count(value)
        frequencies.append(frequency)

hist = pygal.Bar()
hist.title = "矢量图"
hist.x_labels = ['1', '2', '3', '4', '5', '6']
hist.x_title = "骰子投掷结果"
hist.y_title = "出现次数"
hist.add('出现次数', frequencies)
hist.render_to_file('die_visual.svg')

# print(results)
# print(frequencies)